<?php

/**
 * This is the model class for table "user_raovat_info".
 *
 * The followings are the available columns in table 'user_raovat_info':
 * @property integer $raovat_info_id
 * @property integer $user_id
 * @property string $user_name
 * @property string $first_name
 * @property string $last_name
 * @property string $address
 * @property string $phone
 * @property string $mobile
 * @property string $ym
 * @property string $skype
 * @property string $gtalk
 * @property string $msn
 * @property string $aol
 * @property string $about_me
 * @property string $signature
 * @property integer $join_time
 * @property integer $level
 * @property string $avata_url
 */
class UserRaoVatInfo extends CActiveRecord {
    public $website;

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return 'user_raovat_info';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('user_id, user_name, first_name, last_name', 'required'),
            array('user_id, join_time, level', 'numerical', 'integerOnly' => true),
            array('user_name, address, avata_url', 'length', 'max' => 255),
            array('first_name, last_name', 'length', 'max' => 127),
            array('phone, mobile', 'length', 'max' => 15),
            array('ym, skype, gtalk, msn, aol', 'length', 'max' => 100),
            // The following rule is used by search().
            // @todo Please remove those attributes that should not be searched.
            array('raovat_info_id, user_id, user_name, first_name, last_name, address, phone, mobile, ym, skype, gtalk, msn, aol, about_me, signature, join_time, level, avata_url', 'safe', 'on' => 'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations() {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array();
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'raovat_info_id' => 'Raovat Info',
            'user_id' => 'User',
            'user_name' => 'User Name',
            'first_name' => 'First Name',
            'last_name' => 'Last Name',
            'address' => 'Địa chỉ',
            'phone' => 'Phone',
            'mobile' => 'Mobile',
            'ym' => 'Yahoo',
            'skype' => 'Skype',
            'gtalk' => 'Gtalk',
            'msn' => 'Msn',
            'aol' => 'Aol',
            'about_me' => 'About Me',
            'signature' => 'Signature',
            'join_time' => 'Join Time',
            'level' => 'Level',
            'avata_url' => 'Hình đại diện',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     *
     * Typical usecase:
     * - Initialize the model fields with values from filter form.
     * - Execute this method to get CActiveDataProvider instance which will filter
     * models according to data in model fields.
     * - Pass data provider to CGridView, CListView or any similar widget.
     *
     * @return CActiveDataProvider the data provider that can return the models
     * based on the search/filter conditions.
     */
    public function search() {
        // @todo Please modify the following code to remove attributes that should not be searched.

        $criteria = new CDbCriteria;

        $criteria->compare('raovat_info_id', $this->raovat_info_id);
        $criteria->compare('user_id', $this->user_id);
        $criteria->compare('user_name', $this->user_name, true);
        $criteria->compare('first_name', $this->first_name, true);
        $criteria->compare('last_name', $this->last_name, true);
        $criteria->compare('address', $this->address, true);
        $criteria->compare('phone', $this->phone, true);
        $criteria->compare('mobile', $this->mobile, true);
        $criteria->compare('ym', $this->ym, true);
        $criteria->compare('skype', $this->skype, true);
        $criteria->compare('gtalk', $this->gtalk, true);
        $criteria->compare('msn', $this->msn, true);
        $criteria->compare('aol', $this->aol, true);
        $criteria->compare('about_me', $this->about_me, true);
        $criteria->compare('signature', $this->signature, true);
        $criteria->compare('join_time', $this->join_time);
        $criteria->compare('level', $this->level);
        $criteria->compare('avata_url', $this->avata_url, true);

        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
        ));
    }

    /**
     * Returns the static model of the specified AR class.
     * Please note that you should have this exact method in all your CActiveRecord descendants!
     * @param string $className active record class name.
     * @return UserRaoVatInfo the static model class
     */
    public static function model($className = __CLASS__) {
        return parent::model($className);
    }
}
